package shortbread;


import ohos.aafwk.ability.Ability;
import ohos.app.Context;
import ohos.bundle.IBundleManager;
import ohos.rpc.RemoteException;

import java.util.Optional;

/**
 * ShortcutUtils
 */
public class ShortcutUtils {
    /**
     * 获取Ability 的 AbilityLabel
     *
     * @param context context
     * @param cls     Ability
     * @return CharSequence
     */
    public static CharSequence getAbilityLabel(Context context, Class<? extends Ability> cls) {
        IBundleManager iBundleManager = context.getBundleManager();
        try {
            return iBundleManager.getAbilityLabel(context.getBundleName(), cls.getName());
        } catch (RemoteException e) {
            return "";
        }
    }

    private ShortcutUtils() {
    }
}
